<template>
  <div class="app-container">
    <div class="filter-container">
      <el-button type="primary"   @click="addClick()" style="margin-left: 0px">新增</el-button>
      <el-input clearable v-model="search.name" placeholder="银行"  style="width: 170px; margin-left: 10px"></el-input>
      <el-button type="primary" icon="el-icon-search"  @click="searchClick()" style="margin-left: 10px">查询</el-button>
    </div>
    <el-table v-loading="listLoading" :data="list" border
      fit highlight-current-row stripe style="width: 100%">
      <el-table-column align="center" label="序" width="80">
        <template slot-scope="scope">
          <span>{{ scope.row._id }}</span>
        </template>
      </el-table-column>
      <el-table-column min-width="100" align="center" label="融资银行名称">
        <template slot-scope="scope">
          <span>{{ scope.row.bankname }}</span>
        </template>
      </el-table-column>
      <el-table-column min-width="100" align="center" label="融资类型">
        <template slot-scope="scope">
          <span>{{ scope.row.banktype }}</span>
        </template>
      </el-table-column>
      <el-table-column min-width="100" align="center" label="计算比例">
        <template slot-scope="scope">
          <span>{{ scope.row.percent }}</span>
        </template>
      </el-table-column>
      <el-table-column min-width="100" align="center" label="利息率">
        <template slot-scope="scope">
          <span>{{ scope.row.rate }}</span>
        </template>
      </el-table-column>
      <el-table-column min-width="100" align="center" label="三方有效期">
        <template slot-scope="scope">
          <span>{{ scope.row.period }}</span>
        </template>
      </el-table-column>
      <el-table-column min-width="100" align="center" label="状态">
        <template slot-scope="scope">
          <span>{{ scope.row.state }}</span>
        </template>
      </el-table-column>
      <el-table-column min-width="100" align="center" label="日期">
        <template slot-scope="scope">
          <span>{{ scope.row.createtime | parseTime("{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" label="操作" width="220" fixed="right">
        <template slot-scope="scope">
          <el-button type="primary" size="small" @click="tableRowClick().enable(scope.row.id)">启用/禁用</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="listQuery.page"  :limit.sync="listQuery.rows" @pagination="fetchData"/>

<!-- 新增修改 -->
<el-dialog :title="dialogAdd.title" :visible.sync="dialogAdd.visible"  width="700px">
    <div class="ci">
        <div class="item">
            <span class="name required">融资银行</span>
            <span class="value">
                <el-input clearable v-model="dialogAdd.data.bankname" placeholder="" style="width: 220px;"></el-input>
            </span>
        </div>
        <div class="item">
            <span class="name required">融资类型</span>
            <span class="value">
                <el-select v-model="dialogAdd.data.type" clearable placeholder="--" style="width: 220px;">
                    <el-option 
                    v-for="(item,index) in selectOptions.banktype"
                    :key="index"
                    :label="item.label"
                    :value="item.value">
                    </el-option>
                </el-select>
                
            </span>
        </div>
        <div class="item">
            <span class="name required">计算比例</span>
            <span class="value">
                <el-input clearable v-model="dialogAdd.data.percent" placeholder="" style="width: 220px;"></el-input>
            </span>
        </div>
        <div class="item">
            <span class="name required">利息率</span>
            <span class="value">
                <el-input clearable v-model="dialogAdd.data.rate" maxlength="15" placeholder="" style="width: 220px;"></el-input>
            </span>
        </div>
        <div class="item">
            <span class="name required">三方有效期</span>
            <span class="value">
                <el-input clearable v-model="dialogAdd.data.period" maxlength="15" placeholder="" style="width: 220px;"></el-input>
            </span>
        </div>
        
    </div>
    <div slot="footer" class="dialog-footer">
        <el-button @click="dialogAdd.visible = false">取 消</el-button>
        <el-button type="primary" @click="dialogAddClick().save()" :loading="dialogAdd.saveloading">保 存</el-button>
    </div>
</el-dialog>
<!-- end 新增修改 -->





 
  </div>
</template>

<script>
import * as settingApi from '@/api/finance/setting'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import * as enumHelper from '@/utils/enum'

export default {
    components: { Pagination },
    data(){
        return{
          search:{ 
              number:'',
              customer:'',
              phone:'',
              daterange:'',
              filtercomplete:true,
          },
          listQuery: {
                page: 1,
                rows: 20,
                name:'',
                phone:'',
                state:-1,
                daterange:''
          },
          list:null,
          listLoading:false,
          total:0,
          selectOptions:{
            banktype:[]
          },
          dialogAdd:{
              visible:false,
              saveloading:false,
              title:'新增/编辑',
              data:{

              }
          },
          
       }
    
    },
    created(){
        var that=this;
        //初始化下拉菜单
        //enumHelper.initOptions(that.selectOptions.salesState,enumHelper.presale.salesState);
        that.fetchData();
    },
    filters:{
      parseFixType(val){
        return enumHelper.aftersale.fixType.getName(val);
      },
      parseFixCategory(val){
        return enumHelper.aftersale.fixCategory.getName(val);
      },
      parseSettlementState(val){
        return enumHelper.aftersale.settlementState.getName(val);
      }

    },
    methods:{
        fetchData(){
          var that=this;
            settingApi.getThirdbankList({}).then(res=>{
              if(res.data){
                that.list=[...res.data.items.map((item,index)=>{
                  item._id=index+1;
                  return item;
                })];
              }
            })
        },
        refreshClick(){
          this.fetchData();
        },
        addClick(){
            this.dialogAdd.visible=true;
        },
        
        tableRowClick(){
            var that=this;
            return {
                enable(id){
                    
                },
            }
        },
        dialogAddClick(){
            var that=this;
            var dg=that.dialogPay;
            return {
                save(){

                }
            }
        },
        
        
    }
}
</script>

<style>
</style>